package com.weijin.vo;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @Author WeiJin
 * @Version 1.0
 * @Date 2025/3/18 14:07
 */
@Data
@NoArgsConstructor
@ApiModel("分页响应实体")
public class PageVo<T> {
    /**
     * 页码
     */
    @ApiModelProperty("页码")
    private Long pageNumber;
    /**
     * 每页记录数
     */
    @ApiModelProperty("每页记录数")
    private Long pageSize;
    /**
     * 总页数
     */
    @ApiModelProperty("总页数")
    private Long totalPage;

    @ApiModelProperty("总记录数")
    private Long totalCount;
    /**
     * 分页结果信息
     */
    @ApiModelProperty("结果集")
    private List<T> records;

    public PageVo(IPage<T> page) {
        this.pageNumber = page.getCurrent();
        this.pageSize = page.getSize();
        this.totalPage = page.getPages();
        this.totalCount = page.getTotal();
        this.records = page.getRecords();
    }
}
